package aliasMatching.view;

import java.awt.Color;
import java.awt.Component;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

/**
 *
 * @author amendrashrestha
 * This method is responsible for coloring the row of table which displays the
 * average count of selected rows.
 */
public class MyTableCellRender extends DefaultTableCellRenderer {

    public MyTableCellRender() {
        super();
        setOpaque(true);
    }

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value,
            boolean isSelected, boolean hasFocus, int row, int column) {
        //String total = table.getValueAt(row, 1).toString();
        if (isSelected) {
            setBackground(table.getSelectionBackground());
            setForeground(table.getSelectionForeground());
        }

        //System.out.println("String: " + table.getValueAt(row, 0));
        
        else if(table.getValueAt(row, 0) == "Total") {
            setForeground(Color.black);
            setBackground(Color.orange);
        } else {
            setForeground(Color.black);
            setBackground(Color.white);
        }
        setText(value != null ? value.toString() : "");
        return this;
    }
}
